import Q from 'q'

export const cleanClient = (client, loginUser) => {
  return {
    id: client.id,
    nick_name: client.nick_name,
    sex: client.sex,
    head_img_url: client.head_img_url,
    subscribe: client.subscribe,
    mobile_num: client.mobile_num,
    parent_name: client.parent_name,
    city: client.city,
    district: client.district,
    custom_status: client.custom_status,
    custom_property: client.custom_property,
    parent_industry: client.parent_industry,
    source_id: client.source_id,
    parent_job: client.parent_job,
    telephone: client.telephone,
    address: client.address,
    province: client.province,
    qq_num: client.qq_num,
    remark: client.remark,
    wechat_num: client.wechat_num,
    babys: client.babys,
    family: client.family
  }
}

export const getCustomSource = (store) => {
  return Q.Promise((resolve) => {
    store.dispatch('getDictionary', 'custom_source')
      .then((response) => {
        let data = response.data
        let customSourcesData = data.results
        localStorage.setItem('custom_source', JSON.stringify(customSourcesData))
        resolve(customSourcesData)
      })
  })
}
